Need help with currval and nextvall...

Поиск
Список
Период
Сортировка
От Dan Jewett
Тема Need help with currval and nextvall...
Дата
Msg-id p05200f0aba042c71613e@[162.84.132.56]
обсуждение исходный текст
Ответы Re: Need help with currval and nextvall...
Список pgsql-novice
Considering the function below, is it possible to get the value of
the album_id from the first INSERT statement and use it in the 2nd
INSERT statement as I have tried to do here?  Or do has the sequence
not update until the end of the LOOP?

I have tried this and get:  ERROR: Attribute 'album_album_id_seq' not found

How would I accomplish this?

CREATE FUNCTION catalog_batch() RETURNS text AS '

DECLARE
myrec RECORD;

BEGIN
FOR myrec IN SELECT * FROM catalog LOOP

INSERT INTO album (columns,....) VALUES ('matching values',....);

INSERT INTO track (columns,....) VALUES (
currval(album_album_id_seq), 'other matching values',.... );

<rest of code>

END LOOP;
RETURN 'Batch Complete';
END;

'   LANGUAGE 'plpgsql';

Thanks,
Dan Jewett

В списке pgsql-novice по дате отправления:

Предыдущее
От: Dan Jewett
Дата:
Сообщение: ...
Следующее
От: Philip Hallstrom
Дата:
Сообщение: Re: Need help with currval and nextvall...